<?php
// for DEBUG *
ini_set('display_errors', 'on');
error_reporting(E_ALL ^ E_NOTICE);
//

date_default_timezone_set('Asia/Tokyo');
define('SiteManageRootDir', dirname(__FILE__));
//ini_set('include_path', '.');

$libs_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libs';
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $libs_dir);
$include_libs = array(
    'Smarty-3.1.12' . DIRECTORY_SEPARATOR .'libs',
    'plugins',
    'ZendFramework-1.12.0'.DIRECTORY_SEPARATOR.'library'
);
foreach($include_libs as $dir){
    ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $libs_dir . DIRECTORY_SEPARATOR . $dir);
}

$classes_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes';
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $classes_dir);

function __get_config($ini_file_name = '', $process_sections = true)
{
    $ini_dir       = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ini';
    if ($ini_file_name == ''){
        $slice = explode('/', $_SERVER['SCRIPT_NAME']);
        if (file_exists($ini_dir . DIRECTORY_SEPARATOR . $slice[1] . '.ini')){
            $ini_file_name = $slice[1] . '.ini';
        }
        else{
            $ini_file_name = 'config.ini';
        }
    }
    $ini_file_path = $ini_dir . DIRECTORY_SEPARATOR . $ini_file_name;
    return parse_ini_file($ini_file_path, $process_sections);
}
function __raise_error()
{
    echo('ERROR');
    exit();
}
// magic_quotes_gpc = 1 対応
function __stripSlash($data)
{
    $res = array();
    foreach ($data as $key => $value) {
        if (is_array($value)) {
            $value = __stripSlash($value);
        }
        else {
            $value = stripslashes($value);
        }
        $res[$key] = $value;
    }
    return $res;
}
?>